function listener(details) {
    if (details.url.indexOf('mp4') != -1) {
        var originUrl;
        browser.tabs.query({
            currentWindow: true
        }).then((tabs) =>{
            for (var tab of tabs) {
                originUrl = tab.url;
                var json_data = {
                    "url": details.url,
                    "originUrl": originUrl
                };
                console.log(json_data);
                $.ajax({
                    type: "POST",
                    url: "http://localhost:8080/postUrlJson",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(json_data),
                    dataType: "json",
                    success: function(message) {
                        if (message > 0) {
                            console.error("success");
                        }
                    },
                    error: function(message) {
                        console.error("failed");
                    }
                });
                browser.notifications.clear("cake-notification");
                browser.notifications.create("cake-notification", {
                    "type": "basic",
                    "iconUrl": browser.extension.getURL("img/icon.png"),
                    "title": "提取到一个视频url",
                    "message": details.url
                });
            }
        });

    }
}
browser.webRequest.onBeforeSendHeaders.addListener(listener, {
    urls: ["*://*/*"]
});